home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / pcfig4th.zip / 4TH-SYSD.ASM < prev    next >
Assembly Source File  |  1983-07-30  |  4KB  |  194 lines

  1. SUBTTL System dependent code
  2. PAGE
  3.  
  4.  
  5. ;Operating system dependent functions for FIG-FORTH
  6.  
  7. ; This is the ^C interrupt handler code fragment.  The FORTH IP
  8. ; (SI) is loaded with the address of a pointer to the FORTH word
  9. ; (ABORT).  The jump to NEXT starts execution of the interpreter.
  10.  
  11. CTRLC:        PUSH    SI
  12.         MOV    SI,2[BRK]    ;Note: should be CS:2[BRK]
  13.         CMP    SI,0        ;check @BREAK
  14.         JNZ    CC1        ;not zero, (ABORT)
  15.         POP    SI
  16.         IRET            ;zero, don't break
  17. CC1:
  18.         POP    AX        ;adjust stack
  19.         MOV    SI,OFFSET BRK+2
  20.         JMP    NEXT
  21.  
  22. ; This is code to perform system dependent initialization
  23. ; SYSINIT is called just prior to COLD
  24.  
  25. SYSINIT        PROC    NEAR
  26.         MOV    AL,23H        ;^C interrupt no.
  27.         MOV    DX,OFFSET CTRLC
  28.         MOV    AH,25H        ;set ^C addr.
  29.         INT    21H
  30.         RET
  31. SYSINIT        ENDP
  32.  
  33. ;=?+  @BREAK    CFA of function to get control on ^C    -- addr
  34.  
  35.     $VAR    86H,@BREA,K,BRK
  36.     DW    PABOR            ;normal ABORT
  37.  
  38. ;=C*  BYE    exit FORTH                ? -- ?
  39.  
  40.     $CODE    83H,BY,E,BYE
  41.     INT    20H
  42.  
  43.     INCLUDE    4TH-DISK.ASM    ;FIG disk interface
  44.  
  45.     IF    _FILES
  46.     INCLUDE    4TH-FILE.ASM    ;MSDOS file interface
  47.     ENDIF
  48.  
  49.     $REPORT    <MS-DOS disk interface completed>
  50.     $REPORT    <B/BUF    =>,%BUFSIZE
  51.     $REPORT    <B/REC    =>,%RECSIZE
  52.     $REPORT    <BLK/DSK    =>,%BLPDRIVE
  53.  
  54. ;****************************************
  55. ;*                    *
  56. ;*    i/o primitives :        *
  57. ;*                    *
  58. ;*    PQTER, PKEY, PEMIT, PCR,    *
  59. ;*    CONOUT, LSTOUT            *
  60. ;*                    *
  61. ;****************************************
  62. ;
  63.     IF    _DIRECTCON
  64. CONIN        EQU    7
  65. CONOUT        EQU    6
  66.     ELSE
  67. CONIN        EQU    8        ;MSDOS console i/o fctn, no echo
  68. CONOUT        EQU    2        ;MSDOS console output function
  69.     ENDIF
  70. CONSTAT        EQU    11        ;MSDOS console status check fctn
  71.  
  72. LSTOUT        EQU    5        ;MSDOS printer output function
  73.     IF    IOBITS EQ 8
  74. CMASK        EQU    0FFH        ;Use all 8 bits
  75.     ELSE
  76. CMASK        EQU    07FH        ;Use only low 7 bits
  77.     ENDIF
  78. ;
  79. PQTER:
  80.     IF    _DIRECTCON
  81.         MOV    DX,00FFH    ;read keyboard instead
  82.         MOV    AH,CONOUT    ;direct keyboard i/o, no wait
  83.         INT    21H
  84.         SUB    AH,AH        ;AL has char or 0
  85.         JMP    APUSH
  86.     ELSE
  87.         MOV    AH,CONSTAT
  88.         INT    21H
  89.         SUB    AH,AH        ;AL=0FFh if character avail.
  90.         JMP    APUSH
  91.     ENDIF
  92.  
  93. ;=C*  (KEY)    read console primitive            -- c
  94.  
  95.         $CODE    85H,(KEY,),PKEY
  96.         MOV    AH,CONIN
  97.         INT    21H
  98.         AND    AX,CMASK    ;strip unwanted bits
  99.         JMP    APUSH
  100.  
  101. ;=C*  (EMIT)    console char. output primitive        c --
  102.  
  103.         $CODE    86H,(EMIT,),PEMIT
  104.         POP    DX        ;char to send
  105.         CALL    POUT
  106.         JMP    NEXT
  107.  
  108. ;=C*  (CR)    console newline primitive        --
  109.  
  110.         $CODE    84H,(CR,),PCR
  111.         MOV    DX,ACR        ;send carriage return
  112.         CALL    POUT
  113.         MOV    DX,LF        ;and a linefeed
  114.         CALL    POUT
  115.         JMP    NEXT
  116.  
  117. ;Code called by i/o functions above to do console and list output
  118. ;If the variable PRINTER contains 0, the character is sent to the
  119. ;console only.  If PRINTER is positive, the character is sent to the
  120. ;LST device only.  If PRINTER is negative, the character is sent to
  121. ;both the printer and the console.
  122.  
  123. POUT:
  124.         AND    DX,CMASK    ;strip off undesired bits
  125.         MOV    BX,2[PRTER]    ;check PRINTER
  126.         OR    BX,BX        ;zero?
  127.         JZ    CONS        ;console output only
  128.         MOV    AH,LSTOUT    ;non-zero, send to LST
  129.         INT    21H
  130.         JS    PRONLY        ;negative, printer output only
  131. CONS:
  132.     IF    _DIRECTCON AND (IOBITS EQ 8)
  133.         CMP    DL,0FFH        ;try to send 0FF via fn. 6
  134.         JNE    CONS1        ;would wreak havoc, so
  135.         MOV    AH,2        ;do normal console output
  136.         INT    21H
  137.         RET
  138.     ENDIF
  139. CONS1:        MOV    AH,CONOUT    ;send it to the console
  140.         INT    21H
  141. PRONLY:        RET
  142.  
  143.     $REPORT    <MS-DOS i/o primitives completed>
  144.  
  145.     IF    _TIMEANDDATE
  146. ;********************************************************
  147. ;*                            *
  148. ;*        TIME@, TIME!, DATE@, DATE!        *
  149. ;*                            *
  150. ;********************************************************
  151.  
  152. ;=C+  TIME@    fetch system time            -- n1 n2
  153.  
  154.         $CODE    85H,TIME,@
  155.         MOV    AH,2CH        ;Get time
  156.         INT    21H
  157.         PUSH    DX        ;[sec sec/100]
  158.         PUSH    CX        ;[hr min]
  159.         JMP    NEXT
  160.  
  161. ;=C+  TIME!    set system time                n1 n2 --
  162.  
  163.         $CODE    85H,TIME,!!!!
  164.         POP    CX        ;[hr min]
  165.         POP    DX        ;[sec sec/100]
  166.         MOV    AH,2DH        ;set time
  167.         INT    21H
  168.         JMP    NEXT
  169.  
  170. ;=C+  DATE@    fetch system date            -- n1 n2 n3
  171.  
  172.         $CODE    85H,DATE,@
  173.         MOV    AH,2AH        ;get date in CX&DX
  174.         INT    21H
  175.         PUSH    CX        ;year
  176.         MOV    AL,DH        ;month is in DH
  177.         XOR    AH,AH        ;clear high bytes
  178.         XOR    DH,DH
  179.         JMP    DPUSH        ;DL=day
  180.         $CODE    85H,DATE,!!!!
  181.  
  182. ;=C+  DATE!    set system date                n1 n2 n3 --
  183.  
  184.         POP    CX        ;year
  185.         POP    DX        ;DL=day
  186.         POP    AX
  187.         MOV    DH,AL        ;DH=month
  188.         MOV    AH,2BH        ;set date
  189.         INT    21H
  190.         JMP    NEXT
  191.  
  192.     $REPORT    <MS-DOS time and date functions included>
  193.     ENDIF
  194.